<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--<%@page import="com.oracle.xiaomi.pojo.*" %>--%>
<%@page import="java.util.*" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <script type="text/javascript">
    if ("${del}" != "") {
      alert("${del}");
    }
  </script>
  <c:remove var="del"></c:remove>
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.css"/>
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bright.css"/>
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/addBook.css" />
  <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.3.1.js"></script>
  <script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap.js"></script>

  <script type="text/javascript">
    $(document).ready(function () {
      $("#selectAll").click(function(){
        $("[name=\"ids\"]").prop("checked",$(this).prop("checked"));
      });
    });
  </script>
  <title></title>
</head>

<body>
<div id="brall">
  <div id="nav">
    <p>用户管理</p>
  </div>
  <div id="condition" style="text-align: center">
    <form id="myform" action="${pageContext.servletContext.contextPath}/user/mySplict.action" method="post">
      UID：<input name="uid" id="uid" value="${sessionScope.usersVo.uid}">&nbsp;&nbsp;&nbsp;
      昵称：<input name="uname" id="uname" value="${sessionScope.usersVo.uname}">&nbsp;&nbsp;&nbsp;
      <input type="submit" value="查询" />
    </form>
  </div>
  <br>

  <div id="table">
    <c:choose>
      <c:when test="${us.list.size()!=0}">

        <div id="top">
          <div id="middle">
            <table class="table table-bordered table-striped">
              <tr>

                <th>UID</th>
                <th>昵称</th>
                <th>等级</th>
                <th>积分</th>
                <th>状态</th>

              <c:forEach items="${us.list}" var="us">
                <tr>
                  <td>${us.uid}</td>
                  <td>${us.uname}</td>
                  <td>${us.ulevel}</td>
                  <td>${us.score}</td>
                  <td>${us.ustatus}</td>
<%--                  <td>--%>
<%--                  <!-- 第一个按钮 -->--%>
<%--                  <button id="btn1" class="btn red" onclick="toggleButtonColor('btn1')">正常</button>--%>
<%--                  <!-- 第二个按钮 -->--%>
<%--                  <button id="btn2" class="btn green" onclick="toggleButtonColor('btn2')">封禁</button>--%>
<%--                  </td>--%>
                </tr>
              </c:forEach>
            </table>

            <!--分页栏-->
            <div id="bottom">
              <ul class="pagination">
                <li>
                  <a href="#">[总共页${us.pages}]/[当前${us.pageNum}]</a>
                </li>
                <li>
                  <a href="${pageContext.servletContext.contextPath}/user/mySplict.action?page=1&uid=${sessionScope.usersVo.uid}&uname=${sessionScope.usersVo.uname}">首页</a>
                </li>
                <li>
                  <a href="${pageContext.servletContext.contextPath}/user/mySplict.action?page=${us.prePage}&uid=${sessionScope.usersVo.uid}&uname=${sessionScope.usersVo.uname}">上一页</a>
                </li>
                <li>
                  <a href="${pageContext.servletContext.contextPath}/user/mySplict.action?page=${us.nextPage}&uid=${sessionScope.usersVo.uid}&uname=${sessionScope.usersVo.uname}">下一页</a>
                </li>
                <li>
                  <a href="${pageContext.servletContext.contextPath}/user/mySplict.action?page=${us.pages}&uid=${sessionScope.usersVo.uid}&uname=${sessionScope.usersVo.uname}">尾页</a>
                </li>
              <ur/>
            </div>
          </div>
        </form>
      </c:when>
      <c:otherwise>
        <div>
          <h2 style="width:1200px; text-align: center;color: orangered;margin-top: 100px">暂时没有符合条件的商品！</h2>
        </div>
      </c:otherwise>
    </c:choose>
  </div>


</div>

<!--编辑的模式对话框-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">新增商品</h4>
      </div>
      <div class="modal-body" id="addTD">
        <form action="${pageContext.request.contextPath}/admin/product?flag=save" enctype="multipart/form-data" method="post" id="myform">
          <table>
            <tr>
              <td class="one">商品名称</td>
              <td><input type="text" name="pname" class="two" class="form-control"></td>
            </tr>
            <!--错误提示-->
            <tr class="three">
              <td class="four"></td>
              <td><span id="pnameerr"></span></td>
            </tr>
            <tr>
              <td class="one">商品介绍</td>
              <td><input type="text" name="pcontent" class="two" class="form-control"></td>
            </tr>
            <!--错误提示-->
            <tr class="three">
              <td class="four"></td>
              <td><span id="pcontenterr"></span></td>
            </tr>
            <tr>
              <td class="one">定价</td>
              <td><input type="number" name="pprice" class="two" class="form-control"></td>
            </tr>
            <!--错误提示-->
            <tr class="three">
              <td class="four"></td>
              <td><span id="priceerr"></span></td>
            </tr>

            <tr>
              <td class="one">图片介绍</td>
              <td><input type="file" name="pimage" class="form-control"></td>
            </tr>
            <tr class="three">
              <td class="four"></td>
              <td><span></span></td>
            </tr>

            <tr>
              <td class="one">总数量</td>
              <td><input type="number" name="pnumber" class="two" class="form-control"></td>
            </tr>
            <!--错误提示-->
            <tr class="three">
              <td class="four"></td>
              <td><span id="numerr"></span></td>
            </tr>


            <tr>
              <td class="one">类别</td>
              <td>
                <select name="typeid" class="form-control">
                  <c:forEach items="${typeList}" var="type">
                    <option value="${type.typeId}">${type.typeName}</option>
                  </c:forEach>
                </select>
              </td>
            </tr>
            <!--错误提示-->
            <tr class="three">
              <td class="four"></td>
              <td><span></span></td>
            </tr>

            <tr>
              <td>
                <input type="submit" class="btn btn-success" value="提交" class="btn btn-success">
              </td>
              <td>
                <button type="button" class="btn btn-info" data-dismiss="modal">取消</button>
              </td>
            </tr>
          </table>
        </form>

      </div>

    </div>
    <!-- /.modal-content -->
  </div>
  <!-- /.modal -->
</div>
</body>
<!--弹出新增模式对话框-->
<script type="text/javascript">
  $(function () {
    $(".btn-info").on("click", function () {
      //浏览不关，第二次打开时要清空
      $("#myModal").modal("hide");

    });
    //新增学生非空判断
    $(".btn-success").on("click", function () {
      $("#myModal").modal("hide");
    });
  });
</script>
<script type="text/javascript">
  function mysubmit() {
    $("#myform").submit();
  }
  function del(pid,ispage) {
    if (confirm("确定删除吗")) {
      location.href = "${pageContext.request.contextPath}/prod/delete.action?pid="+pid+"&ispage="+ispage;
    }
  }

  function one(pid,ispage) {
    location.href = "${pageContext.request.contextPath}/prod/one.action?pid="+pid+"&ispage="+ispage;
  }
</script>

<!--分页的AJAX实现-->
<script type="text/javascript">
  function split(page) {

    //取出所有的条件
    var uid=$("#uid").val();
    var uname=$("#uname").val();
    var ustatus=$("#lprice").val();

    $.ajax({
      type: "post",
      url: "${pageContext.request.contextPath}/user/ajaxSplit.action",
      data: { "page": page,"uid":uid,"uname":uname,"ustatus":ustatus},
      success: function () {


        $("#table").load("http://localhost:8080/admin/user.jsp #table")
      },
      error: function (e) {
        alert(e.message);
      }
    });
  }
</script>

</html>